/*
* $Id: AddFamilyOperation.cpp 156 2010-09-28 19:00:52Z volok-aleksej@yandex.ru $
*
* Copyright 2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "AddFamilyOperation.h"
#include "FieldValuesOperation.h"
#include "Database/Tables/FamiliesTable.h"
#include "Database/Tables/TableNames.h"
#include "Database/SqlBinder.h"

CAddFamilyOperation::CAddFamilyOperation(){}
CAddFamilyOperation::~CAddFamilyOperation(){}

CAddFamilyOperation::content::content(){
	Clear();
}
void CAddFamilyOperation::content::Clear(){
	s_nIdPoint = 0;
	s_nType = Family::DEFAULT;
	s_nId = 0;
	s_nIdRecord = 0;
	s_strName.clear();
	s_strNote.clear();
	s_aUserFields.clear();
}

void CAddFamilyOperation::AddValue(IDatabase* pDatabase){
	CFieldValuesOperation fvOper;
	fvOper.m_content.s_aUserFields = m_content.s_aUserFields;
	fvOper.m_content.s_table = TypeField::FAMILIES;
	fvOper.AddValue(pDatabase);
	CFamiliesTable families;
	families.m_content.s_strName = m_content.s_strName;
	families.m_content.s_nIdPoint = m_content.s_nIdPoint;
	families.m_content.s_type = m_content.s_nType;
	families.m_content.s_strNote = m_content.s_strNote;
	families.m_content.s_nIdRecord = fvOper.m_content.s_nId;
	families.SetValue(pDatabase);
	m_content.s_nId = families.m_content.s_nId;
	m_content.s_nIdRecord = fvOper.m_content.s_nId;
}